package com.simulation.web.controller.tech;

import com.simulation.common.core.domain.AjaxResult;
import com.simulation.web.dto.TechCollectionPostDTO;
import com.simulation.web.service.impl.CollectionPostServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api("合集与项目关联关系")
@RestController
@AllArgsConstructor
@RequestMapping("techCollectionPost")
public class TechCollectionPostController {

    private final CollectionPostServiceImpl collectionPostService;
    
    /**
     * 删除记录
     *
     * @param collectionPostDTO 待删除的记录
     * @return 返回影响行数
     */
    @PostMapping("delete")
    @ApiOperation("取消项目与合集的关联关系")
    public AjaxResult delete(@RequestBody TechCollectionPostDTO collectionPostDTO) {
        return AjaxResult.success(collectionPostService.delete(collectionPostDTO.getCollectionId(), collectionPostDTO.getPostIdList()));
    }

    @PostMapping("bind")
    @ApiOperation("项目与合集的关联")
    public AjaxResult bind(@RequestBody TechCollectionPostDTO collectionPostDTO) {
        return AjaxResult.success(collectionPostService.insert(collectionPostDTO.getCollectionId(), collectionPostDTO.getPostIdList()));
    }
    
}